﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using mBook.Entity;

namespace mBook.DataAccess
{
    public class BookListDA
    {
        public bool Insert(List<BookList> bookListSet)
        {
            bool result = false;
            using (mBookEntityContextWrapper context = new mBookEntityContextWrapper())
            {
                context.BookLists.InsertAllOnSubmit(bookListSet);
                context.SubmitChanges();
            }

            return result;
        }

        public List<BookList> GetAll()
        {
            List<BookList> result;
            using (mBookEntityContextWrapper context = new mBookEntityContextWrapper())
            {
                result = context.BookLists.ToList();
            }
            return result;
        }

        public bool Remove()
        {
            bool result = false;
            using (mBookEntityContextWrapper context = new mBookEntityContextWrapper())
            {
                List<BookList> list = context.BookLists.ToList();
                context.BookLists.DeleteAllOnSubmit(list);
                context.SubmitChanges();
            }
            result = true;
            return result;        
        }
    }
}
